<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
    </script>
</head>
<body>
<h3>
    注册
</h3>

<br>

用户名:<input id="name" type="text">
<br>
密码:<input id="password" type="text">
<br>
重复密码:<input id="repassword" type="text">
<br>
电话:<input id="tel" type="text">
<br>
地址:<input id="address" type="text">

<br>

<button id="sumbit" type="text">注册</button>


</body>


<script>
    $("#sumbit").click(function(){
        $.ajax({
            url: "json/register",
            type: "post",
            data: {
                name: $("#name").val(),
                password: $("#password").val(),
                tel: $("#tel").val(),
                address: $("#address").val(),
            },
            success: function (result) {
                if (result.registerResult == false) {
                    alert("注册失败,该用户名已经存在")
                }else {
                    alert("注册成功,请前往登录")
                    window.location.href="http://localhost:8080/login";
                }
            }

        })
    });
</script>
</html>